﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Entities.Admin;
using Entities.PBKT;
using BLL.PBKT;

namespace WindowsForms.PBKT
{
	public partial class FormDoiTuyenTKDoiTuyen : Form
	{
		public FormDoiTuyenTKDoiTuyen()
		{
			InitializeComponent();
			dgvThongKe.AutoGenerateColumns = false;
		}
		GiaiDau gd = null;
		List<DoiTuyen> dsDoiTuyen;
		private void FormDoiTuyenTKDoiTuyen_Load(object sender, EventArgs e)
		{
			cbbGiaiDau.DataSource = GiaiDau.Objects.All().ToList();
			cbbGiaiDau.DisplayMember = "TenGiaiDau";
			cbbGiaiDau.ValueMember = "MaGiaiDau";
		}

		private void cbbGiaiDau_SelectedIndexChanged(object sender, EventArgs e)
		{
			gd = cbbGiaiDau.SelectedItem as GiaiDau;
			dsDoiTuyen = DoiTuyen.Objects.Find(c => c.MaGD == gd.MaGiaiDau).ToList();
		}

		private void btnThongKe_Click(object sender, EventArgs e)
		{
			dgvThongKe.DataSource = dsDoiTuyen.OrderBy(c => -c.Diem ).Take(3).ToList();
		}
	}
}
